#pragma once

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"

// char stream -> token

enum class TokenType
{
    unknown, // 未知
    number,  // [0-9]+
    plus,    // +
    minus,   // -
    star,    // *
    slash,   // /
    l_parent,// (
    r_parent,// )
    semi,    // ;
    eof      // end of file
};

class Token
{
public:
    Token()
    {
        row = col = -1;
        tokenType = TokenType::unknown;
        value = -1;
    }
    void Dump();
public:
    int row, col;
    TokenType tokenType;
    int value;
    llvm::StringRef content;
};

class Lexer
{
public:
    Lexer(llvm::StringRef sourceCode);
    void NextToken(Token& token);
public:
    const char * BufPtr;
    const char * LineHeadPtr;
    const char * BufEnd;
    Token token;
    int row;
};